﻿//
// Created by 25007 on 2022/11/15.
//


#include "gtest/gtest.h"
#include "log.h"
#include <fmt/format.h>

/*#include <range/v3/range/conversion.hpp>
#include <range/v3/view/transform.hpp>
#include <range/v3/view/chunk_by.hpp>*/
#include "utility.hpp"
#include <ranges>
#include <algorithm>

import fast_utils;
using namespace fast::util;
namespace fast {

    static int i = 0;

    OnceToken onceToken([] {
        i++;
    }, [] {
        std::cout << "stop";
    });
}

/**
 * @brief
 * @return
 */
int main(int argc, char **argv) {
    Log::instance("player");

    //int i = 666;
    //


    LOG_INFO << fast::i;


    testing::InitGoogleTest(&argc, argv);
    RUN_ALL_TESTS();

    std::vector<std::string> vector{
            "a", "b", "c"
    };

    std::map<std::string, std::string> map{
            {"a", "b"},
            {"c", "d"}
    };

    std::pair<std::string, std::string> string;

    std::for_each(map.begin(), map.end(), [&](auto &item) {
        item.second = "one";
    });


/*  auto names = std::views::keys(map);
 * for (auto &name: names) {
        LOG_INFO << " info " << name.c_str() << " ";
    }
      auto value = vector | std::views::split("a")
                 | std::views::take(1);
    */


    struct Person {
        int Age;
        std::string Name;
    };
    std::vector<Person> persons{
            {.Age=23, .Name = "Alice"},
            {.Age=25, .Name = "Bob"},
            {.Age=23, .Name = "Chad"}};


    struct P {
        int a;
        int b;
    };

    /*  std::vector<Person> test_01 = {
              {.Age=1, .Name= "Alice"},
              {.Age=1, .bName="Bob"},
              {.Age=2, .Name="Chad"}};*/
/*
    for (auto i : persons | ranges::views::chunk_by([](auto l, auto r){  return l.Age = r.Age;})) {
        for (const auto &item: i){
            std::cout << item.Age ;
        }

        std::cout <<'\n';
    }

    auto rg = persons | ranges::views::chunk_by([](Person &a, Person &b) {
        return a.Age = b.Age;
    });

    for (const auto &item_one: rg) {
        for (const auto &item: item_one) {
            LOG_INFO << item.Age << "  " << item.Name;
        }
    }
*/

/*    std::vector<std::thread> vector_thread(5);
    int i[10] = {0};
    std::thread thread([]{

        int i =0;
        while(true){
            fmt::print("cat vector{}",i++);
            Sleep(5);
        }
    });*/
    // vector_thread.push_back(thread);

/*
    for (auto &item: vector_thread){
        item.join();
    }*/
    /* vector_thread.fori*/
   /* std::string buffer = fmt::format("cat vector{}", fmt::join(vector, ", "));

    std::string_view stringView = {buffer.c_str(), buffer.size()};

    LOG_INFO << stringView;

    std::stringbuf string_buf;
    string_buf._Unlock();

    string_buf.~basic_stringbuf();*/
    return 0;
    //
/*  char* data = new char [1000];
  LOG_INFO <<data;
  _CrtDumpMemoryLeaks();*/
    //system("pause");
}